<template>
  <div style="display: flex;">
    <div id="left"></div>
    <div id="center">
      <div style="width: 100%; height: 25%; background-color: #fafafa; box-shadow: 0 2px 4px rgba(0,0,0,.14); margin: 10px 5px;border-radius: 20px; display: flex;">
        <div style="width: 25%; padding: 5px 10px;">

          <el-image
              style="width: 100px; height: 100px; border-radius: 50%; margin-top: 10px;"
              :src="'http://localhost:8081/api/files/' + user.img">
          </el-image>

          <div style="font-size: 16px; font-weight: bold; color: black; margin-left: 10px; margin-top: 5px;">商家名称: {{ user.username }}</div>
          <div style="font-size: 16px; font-weight: bold; color: black; margin-left: 10px; margin-top: 5px;">店铺名称: {{ businessData[0].shopname }} </div>
        </div>
        <div style="width: 20%; padding: 5px 10px;">
          <span style="font-size: 18px; font-weight: bold; color: cornflowerblue;">已售树苗数量</span>
          <div style="color: #B3C0D1;font-weight: bold;">5</div>
        </div>
        <div style="width: 20%; padding: 5px 10px;">
          <span style="font-size: 18px; font-weight: bold; color: cornflowerblue;">在售树苗数量</span>
          <div style="color: red; font-weight: bold;">{{ numData.sumnum }}</div>
        </div>
        <div style="width: 20%; padding: 5px 10px;">
          <span style="font-size: 18px; font-weight: bold; color: cornflowerblue;">在售树苗种类</span>
          <div style="color: greenyellow; font-weight: bold;">{{ numData.countnum }}</div>
        </div>
        <div style="width: 20%; padding: 5px 10px;">
          <span style="font-size: 18px; font-weight: bold; color: cornflowerblue;">邮箱地址</span>
          <div style="color: black; font-size: 15px; font-weight: bold;">{{ user.email }}</div>
        </div>

      </div>
      <div style="width: 100%; height: 75%; margin: 0 5px; border-radius: 20px; ">
        <div style="width: 100px; text-align: center; margin-left: 10px; font-size: 20px; font-weight: bold;background-color: darksalmon; border-radius: 20px;">在售树苗</div>
        <div style="width: 100%; height: auto; border-radius: 20px; margin-top: 5px; background-color: #fafafa; box-shadow: 0 2px 4px rgba(0,0,0,.14);">
          <el-row>
            <el-col :span="5" v-for="item in treeData">
              <img class="treeimg" src="../../assets/imageBox/businessImg/风景树2.webp" alt="">
              <div class="treename">{{ item.treename }}</div>
              <div style="margin-top: 10px; color: burlywood; font-size: 16px; font-weight: bold;">￥: {{ item.treeprice }}元 / 棵</div>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
    <div id="right"></div>
  </div>

</template>
<script>
import request from "@/utils/request";

export default {
  data(){
    return {
      user: JSON.parse(sessionStorage.getItem("user") || {}),
      businessData:[],
      numData:[],   //销售情况部分的信息
      treeData:[],

    }
  },
  created() {
    this.loadshop();
    this.loadnum();
    this.loadTree();
  },
  methods:{
    loadshop(){
      request.post("/user/loadshop",this.user).then(res => {
        if (res.code ==='0'){
          this.businessData = res.data;
          console.log(this.businessData)
        } else {
          this.$message(res.msg);
        }
      })
    },
    loadnum(){
      request.post("/user/loadnum",this.user).then(res => {
        if (res.code ==='0'){
          this.numData = res.data;
        } else {
          this.$message(res.msg);
        }
      })
    },
    loadTree() {
      request.post("/tree/findbuinesstreeinfo/" + this.user.userId).then(res => {
        if (res.code === '0') {
          this.treeData = res.data;
        } else {
          this.$message.error(res.msg);
        }
      })
    },
  }
}

</script>

<style>
#left {
  width: 20%;
  height: 100vh;

}

#center {
  width: 60%;
  height: 100vh;
}

#right {
  width: 20%;
  height: 100vh;
}

</style>